import subprocess
import os
import signal
import time

try:
	cmd = "roslaunch realsense2_camera rs_t265.launch"
	proc = subprocess.Popen(
    	cmd, 
    	shell = True, 
    	stdout = subprocess.PIPE, 
    	stderr = subprocess.STDOUT, 
    	preexec_fn = os.setsid
	)
	
	
	print("start t265 once")
	
	time.sleep(6)
	
	proc.terminate()
	proc.wait()
	os.killpg(proc.pid, signal.SIGTERM)
	print("stop ros once")

except Exception as e:
	print(e)
